package Day2025_04_09;

import java.util.Scanner;

public class Demo04 {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if (n == 1 || n == 2) {
            System.out.println(1);
        } else if (n == 3 || n == 4 || n == 5) {
            System.out.println(4);
        } else {
            long ret = n / 2;
            long tmp1 = 0, tmp2 = 0;
            for (long i = 0; i <= ret; i++) {
                if (i * i >= n) {
                    tmp1 = i * i - n;
                    if (tmp1 < tmp2) {
                        System.out.println(n + tmp1);
                    } else {
                        System.out.println(n - tmp2);
                    }
                    break;
                } else {
                    tmp2 = n - i * i;
                }
            }
        }
    }
}
